#!/bin/sh
source "${LMD_BASE_INSTALL_SCRIPT_DIR}/global/sys_check.sh"
source "$LMD_BASE_INSTALL_SCRIPT_DIR/apps/sillytavern/env"

# if [ ! -n "${NODE_JS_DIR:-}" ]; then
    NODE_JS_DIR="${LMD_DATA_ROOT}/scripts/global-tools/node"
#     echo 'NODE_JS_DIR is empty. set default value.'$NODE_JS_DIR
# fi

echo "NODE_VER_DIR"$NODE_VER_DIR

if [ -f /etc/os-release ]; then
    echo "Linux system."
    echo "Not yet support."
elif [ -f /System/Library/CoreServices/SystemVersion.plist ]; then
    echo "macOS system."
    ARCH=$(uname -m)
    
    CONDA_INSTALL_SCRIPT_URL=""
    if [ "$ARCH" == "x86_64" ]; then
        NODE_VER_DIR=node-v${_NODE_VERSION}-darwin-x64
    elif [ "$ARCH" == "arm64" ]; then
        NODE_VER_DIR=node-v${_NODE_VERSION}-darwin-arm64
    fi
    NODE_BINARY_DIR="$NODE_JS_DIR/$NODE_VER_DIR/bin"
elif current_os_is_windows; then
    echo "Windows system."
    NODE_VER_DIR=node-v${_NODE_VERSION}-win-x64
    NODE_BINARY_DIR="$NODE_JS_DIR/$NODE_VER_DIR"
else
    echo "Unknown OS"
fi

# alias npm="$NODE_JS_DIR/$NODE_VER_DIR/bin/npm"
# alias node="$NODE_JS_DIR/$NODE_VER_DIR/bin/node"

# add node dir to PATH
export PATH=$PATH:"${NODE_BINARY_DIR}/"
